Skip to content

fix(editors): scope Monaco editor instance and add shallow equality to Zustand selectors (#782)#844

Closed
rupeshca007 wants to merge 3 commits intoaccordproject:mainfrom
rupeshca007:fix/782-monaco-race-condition-and-zustand-perf
Closed

fix(editors): scope Monaco editor instance and add shallow equality to Zustand selectors (#782)#844
rupeshca007 wants to merge 3 commits intoaccordproject:mainfrom
rupeshca007:fix/782-monaco-race-condition-and-zustand-perf

Conversation

@rupeshca007
Copy link
Copy Markdown

Summary

Fixes #782 - Syntax error markers attach to wrong editor instances due to global model indexing

Changes

Bug 1: Race Condition Fix (ConcertoEditor.tsx)

  • Replaced non-deterministic monacoInstance.editor.getModels()?.[0] with a scoped useRef (localEditorRef)
  • The editor instance is now captured during handleEditorDidMount
  • Error markers are applied via localEditorRef.current.getModel(), guaranteeing they only attach to the Concerto editor

Bug 2: Performance Fix (9 files)

  • Added shallow from zustand/shallow as the equality function to all object-returning Zustand selectors
  • This prevents unnecessary full component re-renders on every keystroke

Files modified:

  • src/editors/ConcertoEditor.tsx (both fixes)
  • src/App.tsx
  • src/editors/JSONEditor.tsx
  • src/editors/MarkdownEditor.tsx
  • src/components/PlaygroundSidebar.tsx
  • src/components/ProblemPanel.tsx
  • src/components/AIConfigPopup.tsx
  • src/components/AIChatPanel.tsx
  • src/components/CodeSelectionMenu.tsx

Testing

  • All unit tests pass (npm run test:unit)
  • No new lint errors introduced

@rupeshca007 rupeshca007 requested a review from a team as a code owner March 20, 2026 21:41
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 20, 2026

Deploy Preview for ap-template-playground ready!

Name Link
🔨 Latest commit 6a901d9
🔍 Latest deploy log https://app.netlify.com/projects/ap-template-playground/deploys/69c174abb27fe30009e025ce
😎 Deploy Preview https://deploy-preview-844--ap-template-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Signed-off-by: Rupesh <rupeshkuneed@gmail.com>
…o Zustand selectors (accordproject#782)

Bug 1 - Race Condition Fix:
- Replace getModels()?.[0] with scoped useRef in ConcertoEditor.tsx
- Error markers now correctly attach to the Concerto editor only

Bug 2 - Performance Fix:
- Add shallow equality from zustand/shallow to all object-returning
  Zustand selectors across 9 components
- Prevents unnecessary re-renders on every keystroke

Files modified:
- src/editors/ConcertoEditor.tsx (both fixes)
- src/App.tsx
- src/editors/JSONEditor.tsx
- src/editors/MarkdownEditor.tsx
- src/components/PlaygroundSidebar.tsx
- src/components/ProblemPanel.tsx
- src/components/AIConfigPopup.tsx
- src/components/AIChatPanel.tsx
- src/components/CodeSelectionMenu.tsx

Signed-off-by: Rupesh <rupeshkuneed@gmail.com>
@rupeshca007 rupeshca007 force-pushed the fix/782-monaco-race-condition-and-zustand-perf branch from e1d4c76 to 0021e1d Compare March 21, 2026 16:38
@rupeshca007
Copy link
Copy Markdown
Author

Hi @accordproject/maintainers

Could you please approve the CI workflows to run? I've also fixed the DCO sign-off.

Thank you for your time!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Apr 8, 2026
@github-actions github-actions Bot closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntax error markers attach to wrong editor instances due to global model indexing

1 participant